<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org" layout:decorate="main"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head>
    <title>处方划价</title>
    <link th:href="@{/localcss/crmlist.css}" href="../static/localcss/crmlist.css" rel="stylesheet">
    <style>
        #biaoge1{
            float: left;
            margin-left: 30%;
            margin-top: -4%;
        }
        .dataFrm_input{
            float: right;
            margin-left: 10%;
            font-size: 16px;
            width: 150px;
            height: 20px;
            margin-right: 20px;
            margin-bottom: 8px;
        }
        .dataFrm_td{
            display: block;
            width: 80px;
            text-align: right;
        }

    </style>
</head>
<body>
<div layout:fragment="content" style="height: 1000px;background-color:#FAFAFA">
        <div class="clearfix"></div>
            <div class="col-md-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>
                            缴费管理 <i class="fa fa-user"></i>
                            <small>
                                - 您可以通过搜索或者其他的筛选项对用户的信息进行编辑、删除等管理操作。^_^
                            </small>
                        </h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <form method="post" id="dataFrm">
                            <input type="hidden" name="pageIndex" value="1"/>
                            <ul>
                                <li>
                                    <div class="form-group">
                                        <label class="col-md-3 ">编号</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-left: -50px">
                                            <input type="number" name="registerid" id="shows" lay-verify="required|number" autocomplete="off" class="layui-input" style="width:150px;height: 35px" >
                                        </div>

                                        <button type="button" class="btn btn-primary" id="chazhao"> 查 &nbsp;&nbsp;&nbsp;&nbsp;询</button>
                                    </div>

                                </li>

                                <div id="biaoge1" >
                                    <input type="hidden" id="show" name="registerid">
                                    <input type="hidden" id="hidden" name="moneys" value="0">
                                    <table >
                                        <tr >
                                            <td class="dataFrm_td">姓名：</td>
                                            <td><input type="text" id="userName" class="dataFrm_input" name="userName"  readonly></td>
                                            <td class="dataFrm_td">科室：</td>
                                            <td><input type="text" id="department" class="dataFrm_input" name="department" readonly></td>
                                            <td class="dataFrm_td">金额：</td>
                                            <td><input type="text" id="money" class="dataFrm_input" name="money" readonly></td>
                                        </tr>
                                        <tr>
                                            <td class="dataFrm_td">性别：</td>
                                            <td><input type="text" id="sex" class="dataFrm_input" name="sex" readonly></td>
                                            <td class="dataFrm_td" > 医生：</td>
                                            <td><input type="text" class="dataFrm_input" name="doctorName" id="doctorName" readonly></td>
                                            <td class="dataFrm_td">已用：</td>
                                            <td><input type="text" class="dataFrm_input" id="yong" readonly></td>
                                        </tr>
                                        <tr>
                                            <td class="dataFrm_td">年龄：</td>
                                            <td><input type="text" class="dataFrm_input" name="age" id="age" readonly></td>
                                            <td class="dataFrm_td">床位：</td>
                                            <td><input type="text" class="dataFrm_input" name="bedName" id="bedName" readonly></td>
                                            <td class="dataFrm_td">余款：</td>
                                            <td><input type="text" class="dataFrm_input" id="yu" readonly></td>
                                        </tr>
                                    </table>
                                </div>
                            </ul>
                        </form>
                    </div>
<div class="x_panel" style="height: 400px">
    <label class="col-md-2 ">预交金额</label>
    <div class="col-md-6 col-sm-6 col-xs-12" style="margin-left: -130px">
        <input type="number" name="money" id="moneys" lay-verify="required|number" autocomplete="off" class="layui-input" style="width:150px;height: 30px" >
    </div>
    <button type="submit" class="btn btn-primary" style="margin-left: -400px"> 提 &nbsp;&nbsp;&nbsp;&nbsp;交</button>
                    <div class="x_content">
                        <div id="datatable-responsive_wrapper"
                             class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                            <div class="row">
                                <div class="col-sm-12" id="datatable-responsivey">

                                    <table id="datatable-responsive"
                                           class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline collapsed"
                                           cellspacing="0" width="100%" role="grid"
                                           aria-describedby="datatable-responsive_info" style="width: 100%;">
                                        <thead>
                                        <tr role="row">
                                            <th class="sorting_asc" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="First name: activate to sort column descending"
                                                aria-sort="ascending">住院号
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                姓名
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                预交金额
                                            </th>
                                            <th class="sorting" tabindex="0"
                                                aria-controls="datatable-responsive" rowspan="1" colspan="1"
                                                aria-label="Last name: activate to sort column ascending">
                                                交款时间
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody id="tab1">

                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                </div>
            </div>
            </div>

</div>
</body>
<script layout:fragment="js">
    var registerid ="";
    var money="0";
    $("button").click(function () {
        registerid= $("#shows").val()

            money=$("#moneys").val();

        var userName = "";
        var pageIndex=1;
        alert(registerid)
        $.getJSON("/hospital/selPay", {"registerid": registerid,"money":money}, function (data) {
            $(data).each(function () {
                $("#userName").val(this.userName)
                $("#department").val(this.department)
                $("#money").val(this.money)
                $("#doctorName").val(this.doctorName)
                $("#sex").val(this.sex)
                $("#age").val(this.age)
                $("#bedName").val(this.bedName)
                alert(this.userName)
            })
        });
        start(pageIndex,registerid);
        sels();
        return false;
    });

    function start(pageIndex,registerid) {
        $("#x_page1").remove();
        $("#tab1").empty();
        $.ajax({
            type: "post",
            url: '/hospital/selPays',
            data: {"pageIndex": pageIndex,"registerid": registerid},
            dataType: 'json',
            success: function (data) {

                console.info(data.records)
                $(data.records).each(function (index) {
                    var a = "<tr role=\"row\" class=\"odd\" id=\"mobuList1\">" +
                        "<td>" + this.registerid + "</td><td>" + this.userName + "</td>" +
                        "<td>" + this.money + "</td><td>" + this.payDate + "</td>" + "</tr>";
                    $("#tab1").append(a);
                });
                var pagepj = "<div id='x_page1' class=\"row\">\n" +
                    "                                        <div class=\"col-sm-5\">\n" +
                    "                                            <div class=\"dataTables_info\" id=\"datatable-responsive_info\"\n" +
                    "                                                 role=\"status\" aria-live=\"polite\">共<span\n" +
                    "                                                    th:text=\"${paylist.totalElements}\">" + data.size+ "</span>条记录\n" +
                    "                                                <span th:text=\"${paylist.number+1 }\">" + data.current + "</span>/<span\n" +
                    "                                                        th:text=\"${paylist.totalPages }\">" + data.pages + "</span>页\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"col-sm-7\">\n" +
                    "                                            <div class=\"dataTables_paginate paging_simple_numbers\"\n" +
                    "                                                 id=\"datatable-responsive_paginate\">\n" +
                    "                                                <ul class=\"pagination\">\n" +
                    "                                                    <li class=\"paginate_button previous\" th:if=\'${" + data.current + " gt 0}\'><a\n" +
                    "                                                            href=\"javascript:page_navg(1,"+registerid+");\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"0\"\n" +
                    "                                                            tabindex=\"0\">首页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button \" th:if=\'${" + data.current + " gt 0}\'><a\n" +
                    "                                                            href=\"javascript:page_navg(" + (data.current - 1) + ","+registerid+");\"\n" +
                    "                                                            th:onclick=\"'javascript:page_navg(" + (data.current - 1) + ","+registerid+");'\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                    "                                                            tabindex=\"0\">上一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button \"\n" +
                    "                                                        th:if=\'${(" + (data.current + 1) + ") lt " + data.pages + "}\'><a\n" +
                    "                                                            href=\"javascript:page_navg(" + (data.current + 1) + ","+registerid+");\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"1\"\n" +
                    "                                                            tabindex=\"0\">下一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                    <li class=\"paginate_button next\"\n" +
                    "                                                        th:if=\'${(" + (data.current + 1) + ") lt " + data.pages + "}\'><a\n" +
                    "                                                            href=\"javascript:page_navg(" + data.pages + ","+registerid+");\"\n" +
                    "                                                            aria-controls=\"datatable-responsive\" data-dt-idx=\"7\"\n" +
                    "                                                            tabindex=\"0\">最后一页</a>\n" +
                    "                                                    </li>\n" +
                    "                                                </ul>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                    </div>";
                $("#datatable-responsivey").after(pagepj);
            }
        });
        return false;

    }
    function sels(){
        var params=$("#dataFrm").serialize();
        //查询余额

        $.post("selSurplus",params,function(inp) {
            if(inp==""){
                $("#yong").val(0);
            }else{
                $.each(inp, function (index, item) {
                    for(var i in item){
                        if(i=="repicetotal"){
                            $("#yong").val(item[i]);
                        }
                    }
                });
            }
            $("#yu").val($("input[name='money']").val()-$("#yong").val());
        })
    }
</script>